//
// * Copyright (c) 2002-2009 "Neo Technology,"
// *     Network Engine for Objects in Lund AB [http://neotechnology.com]
// *
// * This file is part of Neo4j.
// * 
// * Neo4j is free software: you can redistribute it and/or modify
// * it under the terms of the GNU Affero General Public License as
// * published by the Free Software Foundation, either version 3 of the
// * License, or (at your option) any later version.
// * 
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// * GNU Affero General Public License for more details.
// * 
// * You should have received a copy of the GNU Affero General Public License
// * along with this program. If not, see <http://www.gnu.org/licenses/>.
// 
namespace org.neo4j.kernel.impl.cache
{

///
/// <summary> * Simple cache interface with add, remove, get, clear and size methods. If null
/// * is passed as parameter an <seealso cref="IllegalArgumentException"/> is thrown.
/// * <p>
/// * If the cache cleans it self (for example a LIFO cache with maximum size) the
/// * <CODE>elementCleaned</CODE> method is invoked. Override the default
/// * implementation (that does nothing) if needed.
/// * <p>
/// * TODO: Create a pluggable, scalable, configurable, self analyzing/adaptive,
/// * statistics/reportable cache architecture. Emil will code that in four hours
/// * when he has time. </summary>
/// 
	public interface Cache<K, V>
	{
///    
///     <summary> * Returns the name of the cache.
///     *  </summary>
///     * <returns> name of the cache </returns>
///     
		string Name {get;}

///    
///     <summary> * Adds <CODE>element</CODE> to cache.
///     *  </summary>
///     * <param name="key">
///     *            the key for the element </param>
///     * <param name="element">
///     *            the element to cache </param>
///     
		void put(K key, V value);

///    
///     <summary> * Removes the element for <CODE>key</CODE> from cache and returns it. If
///     * the no element for <CODE>key</CODE> exists <CODE>null</CODE> is
///     * returned.
///     *  </summary>
///     * <param name="key">
///     *            the key for the element </param>
///     * <returns> the removed element or <CODE>null</CODE> if element didn't
///     *         exist </returns>
///     
		V remove(K key);

///    
///     <summary> * Returns the cached element for <CODE>key</CODE>. If the element isn't
///     * in cache <CODE>null</CODE> is returned.
///     *  </summary>
///     * <param name="key">
///     *            the key for the element </param>
///     * <returns> the cached element or <CODE>null</CODE> if element didn't exist </returns>
///     
		V @get(K key);

///    
///     <summary> * Removing all cached elements. </summary>
///     
		void clear();

///    
///     <summary> * Returns the cache size.
///     *  </summary>
///     * <returns> cache size </returns>
///     
		int size();

		void elementCleaned(V value);

		int maxSize();

		void resize(int newSize);

		bool isAdaptive();

		void setAdaptiveStatus(bool status);
	}

}